<template>
	<view class="agreement">
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import {getRules} from '@/api/entrance.js'
	export default{
		name:"agreement",
		data(){
			return{
				titleTabar:"",
				//类型 service_rule服务协议、privacy_rule隐私政策、lord_rule悬赏主规则
				//share_rule邀请好友
				keyword:'service_rule',
				detail:{}
			}
		},
		onLoad(option) {
			this.titleTabar = option.name
			this.keyword = option.keyword ? option.keyword : 'service_rule';
			this.getAgreement(this.keyword);
		},
		methods:{
			async getAgreement(type){
				let res = await getRules({
					keyword:type
				})
				if(res.code ===1){
					if(res.data.length){
						res.data[0].content = res.data[0].content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;" ')
						this.detail = res.data[0]
					}
				}
			}
		},
		watch:{
			titleTabar:{
				handler(newValue){
					if(newValue){
						uni.setNavigationBarTitle({
							title:newValue
						})
					}
				},
				immediate: true
			}
		}
	}
</script>

<style lang="less" scoped src="./agreement.less">
</style>
